home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
ACORNUSERS
/
EMULATOR
/
ASM6502
/
examples
/
c64snow
< prev
next >
Wrap
Text File
|
1998-08-26
|
3KB
|
87 lines
;Screen Scrambler
;Illustrates the technique of using pixel data to manipulate the screen
;and leaving the color information stationary for a wierd effect.
;It does also illustrate the usage of the random number generator and
;the speed impact that self-modifying code gives.
;By Todd S. Elliott
;Updated for asm6502 by Alain BROBECKER, on 04-Aug-1998.
;Works fine with Frodo v4.1 but not with BreadBox64.
#name c64snowX
#type &064
#list
#base &801-2
#set vicontrol = 53272 ;vic control register
#set scrmem = 1024 ;location of screen memory
#set vic = 53248 ;vic ii chip register
#set multiclr = 53270 ;multi-color register
#set charbase = 14336 ;char base address
#set backgnd = 53281 ;background color register
#set multi1 = 53282 ;multi-color register one
#set multi2 = 53283 ;multi-color register two
#set frehi3 = 54287 ;frequency register three
#set vcreg3 = 54290 ;voice control register three
#set sigvol = 54296 ;oscillator three
#set random = 54299 ;random generator
;---- C64 specific part... loading adress+BASIC stuff --------------------------
#rw &0801 ;Load adress (C64)
#rw BasicEnd,1997 ;Adress of next line + line number
#b &9e,&32,&30,&36,&32 ;Basic "SYS 2062" instruction
#b 0 ;End of basic line
.BasicEnd
#b 0,0,0 ;End of basic program
;---- Assembly language ForEVER ------------------------------------------------
.start
;initializes the screen
lda #151 ;char code for color dark gray
jsr &ffd2 ;changes video color matrix color to dark gray
lda #147:jsr &ffd2 ;clears the screen
lda #&ff ;set voice three to max.
sta frehi3
lda #128
sta vcreg3
sta sigvol ;turn on random generator for random numbers
ldy #&00 ;load offset
.back0:tya ;transfer to accumulator
sta scrmem,y ;store char code
sta scrmem+256,y
sta scrmem+512,y
sta scrmem+768,y
dey ;decrement offset
bne back0 ;if not equal, branch back
lda vicontrol ;get the values of the vic control register
and #240 ;protect bits
ora #14 ;store offset
sta vicontrol ;change the modified value to point to 14336
lda multiclr ;get the bit values of the multi color register
ora #16 ;turn on bit 4
sta multiclr ;switch on multi color
lda #&00 ;color black
sta 53280 ;border register
;starts the whole shebang!
;This uses self-modifying code for the sake of speed and efficiency.
lda #&01
sta multi1
lda #&00
sta backgnd
lda #&0f
sta multi2
.back1:lda #charbase AND &ff ;low byte
ldy #charbase>>8 ;high byte
sta base+1
sty base+2
ldx #&07 ;x-offset
.back2:ldy #&00 ;y-offset
.back3:lda random ;get a random number
.base:sta &ffff,y ;and store it into mem.
dey
bne back3 ;decrement 256 counter and loop back
inc base+2 ;decrement high byte of character base
dex
bpl back2 ;decrements the page counter and branches back
jmp back1 ;ad infinitum...